package tp.pr5.console;

import java.util.ArrayList;

import tp.pr5.Direction;
import tp.pr5.Main;
import tp.pr5.NavigationObserver;
import tp.pr5.PlaceInfo;
import tp.pr5.RobotEngineObserver;
import tp.pr5.items.InventoryObserver;
import tp.pr5.items.Item;

public class Console implements RobotEngineObserver,NavigationObserver,InventoryObserver{

	@Override
	public void communicationCompleted() {		
		
	}

	@Override
	public void communicationHelp(String help) {
		System.out.println(help);
		
	}

	@Override
	public void engineOff(boolean atShip) {
		if(atShip)
			System.out.println("WALL·E says: I am at my spaceship. Bye bye");
		else
			System.out.println("WALL·E says: I am out of fuel, shutting down");
		
	}
	/**
	 * Envía los mensajes de las excepciones a la salida de error, desactivado por cuestiones del validador
	 */
	@Override
	public void raiseError(String msg) {
		System.out.println(msg);	
	}

	@Override
	public void robotSays(String message) {		
		System.out.println(message);	
	}

	@Override
	public void robotUpdate(int fuel, int recycledMaterial) {
		System.out.println("      * My power is "+fuel+Main.LINE_SEPARATOR+
				   		   "      * My recycled material is "+recycledMaterial);
		
	}

	@Override
	public void headingChanged(Direction newHeading) {
		System.out.println("WALL·E is looking at direction "+newHeading);
		
	}

	@Override
	public void initNavigationModule(PlaceInfo initialPlace, Direction heading) {
		System.out.println(initialPlace.toString()+Main.LINE_SEPARATOR);			
		headingChanged(heading);
	}

	@Override
	public void placeHasChanged(PlaceInfo placeDescription) {
		/*String text = placeDescription.getName() + Main.LINE_SEPARATOR
		+placeDescription.getDescription()       + Main.LINE_SEPARATOR; // salto de linea 
		
		System.out.println(text);	*/	
	}

	@Override
	public void placeScanned(PlaceInfo placeDescription) {
		System.out.println(placeDescription.toString());		
	}

	@Override
	public void robotArrivesAtPlace(Direction heading, PlaceInfo place) {		
		System.out.println("WALL·E says: Moving in direction "+heading.toString());
		System.out.println(place.toString()+Main.LINE_SEPARATOR);
	}

	@Override
	public void inventoryChange(ArrayList<Item> inventory) {		
		
	}

	@Override
	public void inventoryScanned(String inventoryDescription) {
		robotSays(inventoryDescription);
		
	}

	@Override
	public void itemEmpty(String itemName) {
		System.out.println("WALL·E says: What a pity! I have no more "+itemName+" in my inventory");
		
	}

	@Override
	public void itemScanned(String description) {
		robotSays(description);
		
	}

	@Override
	public void unVisitPlace(PlaceInfo lastPlace) {
				
	}

}
